import { Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { UserEntity } from '../../../app/entity/user';
const os = require('os');
/**
 * 描述
 */
@Provide()
export class BaseSysDashboardService extends BaseService {
    @InjectEntityModel(UserEntity)
    userEntity: Repository<UserEntity>;

    /**
     * 描述
     */
    async getDashboardInfo() {
        return {
            userCount: await this.userEntity.count(),
            boyCount: await this.userEntity.count({
                where: {
                    sex: 1,
                },
            }),
            girlCount: await this.userEntity.count({
                where: {
                    sex: 2,
                },
            }),
            systemInfo: {
                type: os.type(),
                totalmem: (os.totalmem() / 1024 / 1024 / 1024).toFixed(2) + ' GB',
                arch: os.arch(),
            },
        };
    }
}
